//
//  ViewController.m
//  1504兔子
//
//  Created by 小白 on 16/2/21.
//  Copyright © 2016年 小白. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSMutableArray *arr = [NSMutableArray array];
    for (int i=1; i<=20; i++) {
        NSString *img = [NSString stringWithFormat:@"frame-%d",i];
        UIImage *imgname = [UIImage imageNamed:img];
        [arr addObject:imgname];
    }
    
    self.uiImage.animationDuration=2;
    self.uiImage.animationImages = arr;

}
//-(void)imageChange {
//    NSMutableArray *arr = [NSMutableArray array];
//    for (int i=1; i<=20; i++) {
//        NSString *img = [NSString stringWithFormat:@"frame-%d",i];
//        UIImage *imgname = [UIImage imageNamed:img];
//        [arr addObject:imgname];
//    }
//    
//    //self.uiImage.animationDuration=2-[self.labelslider.text doubleValue];
//    self.uiImage.animationImages = arr;
//    
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)bntrabitjump:(id)sender {
//    double time = 2- self.sliderspeed.value;
//    [self imageChange:time];
//    
//    if ([self.btncontrol.titleLabel.text isEqualToString:@"跳"]) {
//        self.btncontrol.titleLabel.text = @"停";
//        [self imageChange];
//        [self.uiImage startAnimating];
//        
//    }
//    else{
//         self.btncontrol.titleLabel.text = @"跳";
//       
    
//    }
    if(self.uiImage.isAnimating)
    {
        [self.uiImage stopAnimating];
        [self.btncontrol setTitle:@"跳" forState:UIControlStateNormal];
    }
    else
    {
        [self.uiImage startAnimating];
        [self.btncontrol setTitle:@"停" forState:UIControlStateNormal];
    }

    
}


- (IBAction)sliderchange:(UISlider *)sender {
    self.uiImage.animationDuration = 2 - sender.value;
    if(self.uiImage.isAnimating )
    {
        [self.uiImage startAnimating];
    }
    else
    {
        
    }
    
}

@end
